<style>
    .xxpayPopupDiv .layui-form-label {
        width:15% !important;
        margin-left:1%;
    }
    .xxpayPopupDiv .layui-input-inline {
        width: 33% !important;
        margin-top: 0px;
    }
    .xxpayPopupDiv #privateKeyDiv .layui-form-label {
        width: 120px !important;
    }
    .xxpayPopupDiv #privateKeyDiv .layui-form-item{
        margin-bottom: 10px;
    }
    .xxpayPopupDiv #privateKeyDiv .layui-input-inline {
        width: 190px !important;
        margin-top: 0;
    }
    .xxpayPopupDiv #privateKeyDiv .layui-input-inline .layui-input{
        border: none;
        padding-left: 0;
        color: red;
    }
    .xxpayPopupDiv #privateKeyDiv .layui-input-inline .verify-input{
        padding-left: 0;
        border-bottom: 1px solid #e6e6e6;
        border-radius: 0;
        color: black;
    }
</style>
<div class="layui-fluid">
  <div class="layui-card">
      <div class="layui-tab-content" id="privateKeyDiv">
          <form class="layui-form center" lay-filter="privateKeyDivForm">
              <div class="layui-form-item">
                  <label class="layui-form-label">商户订单号:</label>
                  <div class="layui-input-inline" style="width: 220px">
                      <input type="text" readonly id="mchOrderNoConfirm" disabled class="layui-input">
                  </div>
              </div>
              <div class="layui-form-item">
                  <label class="layui-form-label">支付订单号:</label>
                  <div class="layui-input-inline" style="width: 220px">
                      <input type="text" readonly id="payOrderIdConfirm" disabled class="layui-input">
                  </div>
              </div>
              <div class="layui-form-item">
                  <label class="layui-form-label">订单金额:</label>
                  <div class="layui-input-inline" style="width: 220px">
                      <input type="text" id="confirmBankName" readonly disabled class="layui-input">
                  </div>
              </div>
              <div class="layui-form-item">
                  <label class="layui-form-label">创建时间:</label>
                  <div class="layui-input-inline" style="width: 220px">
                      <input type="text" readonly id="createTimeConfirm" disabled class="layui-input">
                  </div>
              </div>
              <div class="layui-form-item">
                  <label class="layui-form-label">实付金额(元):</label>
                  <div class="layui-input-inline" style="width: 220px">
                      <input type="text" id="realAmount" name="realAmount" placeholder="请输入实付金额" class="layui-input verify-input">
                  </div>
              </div>
              <div class="layui-form-item">
                  <label class="layui-form-label">备注:</label>
                  <div class="layui-input-inline" style="width: 220px">
                      <input type="text" id="remark" name="remark" placeholder="请输入备注" class="layui-input verify-input">
                  </div>
              </div>
              <div class="layui-form-item">
                  <label class="layui-form-label">平台超级密码:</label>
                  <div class="layui-input-inline" style="width: 220px">
                      <input type="password" id="password" name="amount" lay-verify="required" placeholder="请输入平台超级密码" class="layui-input verify-input">
                  </div>
              </div>
              <div class="layui-form-item" style="text-align: center;margin-top: 20px;">
                  <button type="button" lay-filter="btnPrivateKey" lay-submit class="layui-btn layui-btn-sm">确认到账</button>
              </div>
          </form>
      </div>
  </div>
</div>

<script>
layui.use(['admin','form', 'table'],function(){
    var form = layui.form
    ,$ = layui.$
    ,admin = layui.admin
    ,element = layui.element
    ,layer = layui.layer
    ,table = layui.table
    ,view = layui.view;

    // 导航
    element.render('breadcrumb', 'breadcrumb');

    var payOrderId = view.getOpenParams('payOrderId');
    var amount = view.getOpenParams('amount');
    var mchOrderNo = view.getOpenParams('mchOrderNo');
    var createTimeConfirm = view.getOpenParams('createTimeConfirm');

    var orderAmount = amount / 100;
    $("#realAmount").val('');
    $("#mchOrderNoConfirm").val(mchOrderNo);
    $("#payOrderIdConfirm").val(payOrderId);
    $("#createTimeConfirm").val(layui.util.toDateString(createTimeConfirm, "yyyy-MM-dd HH:mm:ss"));
    $("#confirmBankName").val(orderAmount + " 元");

    //监听提交
    form.on('submit(btnPrivateKey)', function (data) {
      var password = $("#password").val();
      if (data.field.realAmount.trim() && orderAmount != data.field.realAmount.trim()) {
        layer.confirm('订单金额'+orderAmount + '元，确认实付金额'+data.field.realAmount.trim()+'元，是否继续？', {
          btn: ['确认到账','返回']
        }, function() {
          reissueReq(password, payOrderId, data.field.realAmount.trim(), data.field.remark);
        })
      }else {
        reissueReq(password, payOrderId, data.field.realAmount.trim(), data.field.remark);
      }
    })

    var reissueReq = function(password, payOrderId, realAmount, remark) {
        var layerMsgId = layer.msg('请等待，正在确认... ',{time: 0, shade: 0.3});
        admin.req({
            type: 'post',
            url: layui.setter.baseUrl + '/pay_order/reissue',
            data: {
                password: password,
                payOrderId: payOrderId,
                realAmount: realAmount,
                remark: remark
            },
            complete: function() {
                layer.close(layerMsgId);
            },
            success: function (res) {
                layer.close(layerMsgId);
                if (res.code == 0) {
                    layer.alert("补单成功", {title: '提示'}, function (index) {
                        layer.closeAll();
                        table.reload("tableReload");
                    });
                }
            }
        });
    };

})
</script>